package com.ioc.business.order.enums;

import cn.hutool.core.util.StrUtil;
import com.ioc.common.enums.BaseEnum;
import lombok.AllArgsConstructor;

@AllArgsConstructor
public enum OrderStatusEnum implements BaseEnum {
    NORMAL("normal", "正常"),
    FINISH("finish", "完成"),
    OVERDUE("overdue", "逾期");


    private final String value;
    private final String desc;


    @Override
    public String getDesc() {
        return desc;
    }

    @Override
    public String getValue() {
        return value;
    }

    public static String getDesc(OrderStatusEnum em) {
        for (OrderStatusEnum value : OrderStatusEnum.values()) {
            if (value.equals(em)) {
                return value.getDesc();
            }
        }
        return StrUtil.EMPTY;
    }

    public static OrderStatusEnum getByDesc(String desc) {
        for (OrderStatusEnum value : OrderStatusEnum.values()) {
            if (value.desc.equals(desc)) {
                return value;
            }
        }
        return null;
    }

}
